package com.wiscamp.ninechapters.tags.domain.repositories;

import com.wiscamp.ninechapters.tags.domain.models.KnowledgePoint;
import com.wiscamp.ninechapters.tags.domain.models.KnowledgePointRelation;
import com.wiscamp.ninechapters.tags.domain.models.KnowledgeTreePoint;
import com.wiscamp.ninechapters.tags.enums.PointRelationTypes;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;

import java.util.Collection;

public interface KnowledgePointRepository {
    // region knowledgePoint
    KnowledgePoint getKnowledgePoint(@Min(0) long pointId);

    KnowledgePoint getKnowledgePointByCode(@NotBlank String pointCode, @Min(0) long subjectId);

    KnowledgePoint getFirstKnowledgePointByName(@NotBlank String pointName, @Min(0) long subjectId);

    Collection<KnowledgePoint> getKnowledgePointsByName(@NotBlank String pointName, @Min(0) long subjectId);

    Collection<KnowledgePoint> getKnowledgePointsByNameContains(@NotBlank String name, @Min(0) long subjectId);

    Collection<KnowledgePoint> getKnowledgePointsBySubject(@Min(0) long subjectId);

    Collection<Long> getKnowledgePointIdsBySubject(@Min(0) long subjectId);

    Collection<KnowledgePoint> getKnowledgePointsByIds(@NotBlank Collection<Long> pointIds);

    Collection<KnowledgePoint> getRandomKnowledgePoints(@Min(0) long subjectId, int quantity);

    KnowledgePoint saveKnowledgePoint(@NotNull KnowledgePoint point);
    // endregion

    // region point relation
    KnowledgePointRelation getKnowledgePointRelation(@Min(0) long id);

    Collection<KnowledgePointRelation> getKnowledgePointRelationsBySource(long sourceId);

    Collection<KnowledgePointRelation> getNonAggregationRelationsBySource(@Min(0) long sourceId);

    KnowledgePointRelation getKnowledgePointRelation(long sourceId, long targetId, PointRelationTypes relationType);

    Collection<Long> getChildKnowledgePointIds(@NotEmpty Collection<Long> parentIds);

    Collection<Long> getKnowledgePointIdsByParent(@NotBlank Collection<Long> parentIds);

    void deleteKnowledgePointRelation(@Min(0) long id);

    KnowledgePointRelation saveKnowledgePointRelation(@NotNull KnowledgePointRelation relation);

    // endregion

    // region knowledgePointTree
    Collection<KnowledgeTreePoint> getKnowledgeTreePointsBySubject(@Min(0) long subjectId);

    Collection<KnowledgeTreePoint> getKnowledgeTreePointsByParent(@Min(0) long subjectId, @Min(0) long parentId);

    Collection<KnowledgeTreePoint> getKnowledgeTreePointsByIds(@Min(0) long subjectId, Collection<Long> pointIds);
    // endregion
}
